package structures;

import java.util.*;
import structures.NoticeContent;
import structures.Paragraph;
import structures.Picture;

/**
 * Notice
 * @author Jose Antonio Prieto
 */
public class Notice {

    // =========== Attributes of a Notice ===========
    /** Id of the Notice */
    private String id;
    /** Owner of the Notice */
    private String owner;
    // =========== Application Fields of a Notice ===========
    /** The title of the Notice */
    private String title;
    /** Array of noticeContent */
    private ArrayList<NoticeContent> nc;
    /** URL of the Image */
    private ArrayList<String> URL;

    /**
     * Constructor
     */
    public Notice() {
        // Atributes Initialization
        id = "";
        owner = "";
        // Application Fields Initialization
        title = "";
        nc = new ArrayList<NoticeContent>();
        URL = new ArrayList<String>();
    }
       
	/**
	 * Getter
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * Setter
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * Getter
	 * @return the owner
	 */
	public String getOwner() {
		return owner;
	}

	/**
	 * Setter
	 * @param owner the owner to set
	 */
	public void setOwner(String owner) {
		this.owner = owner;
	}

	/**
	 * Getter
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * Setter
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * Getter
	 * @return the nc
	 */
	public ArrayList<NoticeContent> getNc() {
		return nc;
	}
	
	/**
	 * For adding noticeContent
	 * @param notCont
	 */
	public void addNoticeContent(NoticeContent notCont){
		nc.add(notCont);
	}

	/**
	 * @return the uRL
	 */
	public ArrayList<String> getURL() {
		return URL;
	}
	
	public void addURL(String URL){
		this.URL.add(URL);
	}

	/**
     * Print of the Notice
     * @return
     */
    public String toString() {
        String res = "<--Notice-->\n";
        if (!id.equals("")){
            res += "\tID: " + id + "\n";
        }
        if(!owner.equals("")) {
            res += "\tOwner: " + owner + "\n";
        }
        if (!title.equals("")) {
            res += "\tTitle: " + title + "\n";
        }
        if (!nc.isEmpty()) {
        	res += "\t<--NoticeContent-->\n";
        	for(NoticeContent n : nc){
        		if(n instanceof Paragraph){
        			Paragraph p = (Paragraph)n;
        			res += "\t\tParagraph: " +p.getParagraph()+ "\n";
        		} else if (n instanceof Picture) {
        			Picture p = (Picture)n;
        			res += "\t\tPicture: " +p.getPicture()+ "\n";
        		}
        	}            
        }        
        if (!URL.isEmpty()) {
        	for(String s : URL){
        		res += "\tURL: " + s + "\n";
        	}            
        }
        return res;
    }
}	
